<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006~2018 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: liu21st <liu21st@gmail.com>
// +----------------------------------------------------------------------


use think\Route;

// Banner
Route::get('api/:version/banner/:id','api/:version.Banner/getBanner');

// Theme
// 分组路由，推荐使用闭包的方式，数组的方式不允许有同名的key
Route::group('api/:version/theme',function (){
    Route::get('','api/:version.Theme/getSimpleList');
    Route::get('/:id','api/:version.Theme/getComplexOne');
    Route::post('/:t_id/product/:p_id','api/:version.Theme/addThemeProduct');
    Route::delete('/:t_id/product/:p_id','api/:version.Theme/deleteThemeProduct');
});

// Product
Route::group('api/:version/product',function (){
    Route::get('/:id','api/:version.Product/getOne',[],['id' => '\d+']);
    Route::get('/recent','api/:version.Product/getRecent');
    Route::get('by_category/paginate','api/:version.Product/getByCategory');
    Route::get('by_category','api/:version.Product/getAllInCategory');
    Route::post('','api/:version.Product/createOne');
    Route::delete('/:id','api/:version.Product/deleteOne');
});

// Category
Route::get('api/:version/category','api/:version.Category/getCategories');
Route::get('api/:version/category/all','api/:version.Category/getAllCategories');
Route::get('api/:version/category/:id','api/:version.Category/getCategory');

// Token
Route::post('api/:version/token/user','api/:version.Token/getToken');
Route::post('api/:version/token/verify','api/:version.Token/verifyToken');

// Address
Route::post('api/:version/address','api/:version.Address/createOrUpdateAddress');
Route::get('api/:version/address','api/:version.Address/getUserAddress');

// Order
Route::post('api/:version/order','api/:version.Order/placeOrder');
Route::get('api/:version/order/:id','api/:version.Order/getDetail',[],['id'=>'\d+']);
Route::get('api/:version/order/by_user','api/:version.Order/getSummaryByUser');
Route::get('api/:version/order/paginate','api/:version.Order/getSummary');
Route::put('api/:version/order/delivery','api/:version.Order/delivery');

// Pay
Route::post('api/:version/pay/pre_order','api/:version.Pay/getPreOrder');
Route::post('api/:version/pay/re_notify','api/:version.Pay/redirectNotify');